#ifndef _LOG_H_
#define _LOG_H_
#include <stdint.h>

void log1(const char * restrict format, ...);
#define LEVEL_VERBOSE       1
#define LEVEL_INFO          2
#define LEVEL_DEBUG         3
#define LEVEL_WARNING       4
#define LEVEL_ERROR         5
#define LEVEL_NONE          6

#define __LEVEL__   LEVEL_VERBOSE

#if 1
void __log(uint8_t level, const char * func, uint32_t line, const char * restrict format, ...);
void log_xx(uint8_t level, const char * func, uint32_t line, const char * restrict format, ...);
#if defined(DEBUG_LOG)
#define LOG_X(format, ...)  __log(LEVEL_INFO, __func__, __LINE__, format, ##__VA_ARGS__)
#else
#define LOG_X(format, ...) log_xx(LEVEL_INFO, __func__, __LINE__, format, ##__VA_ARGS__)
#endif
#else
#define LOG(level, format, ...)                   \
        if( level >= __LEVEL__ ) {                                          \
        char    str[64];                                \
        snprintf(str, sizeof(str), "[%d|%s|%d]"format,      \
        level,__func__,__LINE__,##__VA_ARGS__);\
        simple_uart_putstring((const uint8_t *)str);                    \
        }
#endif

#endif
